package com.huawei.appmarket.service.externalapi.actions;

import android.content.Intent;
import android.text.TextUtils;
import java.util.Locale;
import o.Logger;
import o.dyr;
import o.dys.a;
import o.egu;
import o.egv;
import o.egv.b;

public class ContentRestrictAction extends dyr implements b {
    private static final String PARENT_CONTROL_PACKAGE = "com.huawei.parentControl";
    private static final String TAG = "ContentRestrictAction";
    private String clientName;
    private int oldGradeId = -1;
    private String packageName;

    public ContentRestrictAction(a aVar) {
        super(aVar);
    }

    public void onAction() {
        this.clientName = this.callback.getIntent().getStringExtra("content_restrict_client_name");
        this.packageName = this.callback.getIntent().getStringExtra("content_restrict_client_package");
        if (TextUtils.isEmpty(this.packageName)) {
            this.packageName = PARENT_CONTROL_PACKAGE;
        }
        this.oldGradeId = egv.ॱᐝ().ॱˊ();
        Logger.ˎ(TAG, String.format(Locale.ENGLISH, "onAction: from:%s reloadStatus", new Object[]{this.packageName}));
        egv.ॱᐝ().ˏ(this);
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        Logger.ˎ(TAG, "onActivityResult: requestCode:" + i + " resultCode:" + i2);
        this.callback.setResult(i2, intent);
        this.callback.finish();
    }

    public String getPermission() {
        return "com.huawei.appmarket.permission.ACCESS_RESTRICTIONS";
    }

    public void onComplete() {
        gotoActivity(egv.ˊ(this.oldGradeId, egv.ॱᐝ().ॱˊ()));
    }

    private void gotoActivity(boolean z) {
        Logger.ˎ(TAG, "gotoActivity: needForceReboot:" + z);
        egu.a aVar = new egu.a();
        aVar.ˋ(this.clientName);
        aVar.ॱ(this.packageName);
        aVar.ˋ(z);
        this.callback.ˎ(egu.ˏ(aVar), 0);
        this.callback.finish();
    }
}
